package com.syn.michat.util.Interceptor;

import org.springframework.context.annotation.Bean;
import org.springframework.context.annotation.Configuration;
import org.springframework.web.servlet.config.annotation.InterceptorRegistry;
import org.springframework.web.servlet.config.annotation.WebMvcConfigurationSupport;
import org.springframework.web.servlet.config.annotation.WebMvcConfigurer;

/**
 * 拦截器
 **/

@Configuration
public class InterceptorConfig implements WebMvcConfigurer {

    @Bean
    public TokenInterceptor tokenInterceptor() {
        return new TokenInterceptor();
    }

    @Override
    public void addInterceptors(InterceptorRegistry registry) {
        registry.addInterceptor(tokenInterceptor())
//                //排除路径
                .excludePathPatterns("/avatar/**")
                .excludePathPatterns("/image/**")
                .excludePathPatterns("/error/**")
                .excludePathPatterns("/account/login")
                .excludePathPatterns("/account/register")
                .addPathPatterns("/**");
    }

}
